package com.uinnova.springboot.swagger;

import com.sun.org.apache.bcel.internal.generic.RETURN;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@RestController
@Api
/*
*@author 王刚
*@date 2019-01-09 14:00
*@validated校验数据，
*/
@Validated
public class SwaggerController {
    /*
    *@author 王刚
    *@date 2019-01-09 14:58
    * @ApiIgnore()swagger中忽略此方法
    */
//    @ApiIgnore()
    @GetMapping(value = "/jail/swagger")
    public Swagger testSwagger(@Validated Swagger swagger){
        System.out.println(swagger);
        return swagger;
    }

//    @ApiIgnore()
    @GetMapping(value = "/jail/swagger/bean")
    public Swagger testSwaggerBean(@Validated Swagger swagger){
        System.out.println(swagger);
        return swagger;
    }

//    测试restful
    @GetMapping(value = "/jail/swagger/{id}")
    @ApiOperation(value = "测试restful",notes = "参数在url中",httpMethod = "GET")
    public void ceshirestful(@PathVariable String id){
       System.out.println("测试restful的id为："+id);
    }

//    测试表单
    @PostMapping(value = "/jail/swagger/param1")
    @ApiOperation(value = "测试表单",notes = "参数为lists=111&lists=2222或者lists=124124,13213",httpMethod = "POST")
    public List<String> testParamPost(@RequestParam  List<String> lists, String name){
        return lists;
    }
}
